package com.heaven.controller;

import com.heaven.pojo.Lead;
import com.heaven.service.LeadService;
import com.heaven.vo.PageResult;
import com.heaven.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/lead")
@CrossOrigin
public class LeadController {
    @Autowired
    private LeadService leadService;
    @GetMapping("/list")
    public SysResult addreList(PageResult pageResult){

        pageResult=leadService.addreList(pageResult);
        return SysResult.success(pageResult);
    }
    @DeleteMapping("/deleteLeadById")
    public SysResult deleteLeadById(Integer id){
        leadService.deleteLeadById(id);
        return SysResult.success();
    }
    @GetMapping("/{id}")
    public SysResult findLeadById(@PathVariable Integer id){
        Lead lead=leadService.findLeadById(id);
        return SysResult.success(lead);
    }

    @PutMapping("/updateLead")
    public SysResult updateLead(@RequestBody Lead lead){
        leadService.updateLead(lead);
        return SysResult.success();
    }
}
